package com.bxx.ermall.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bxx.ermall.common.dto.SiteDto;
import com.bxx.ermall.common.dto.SiteListDto;
import com.bxx.ermall.entity.GoodsSite;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author buxiaoxing
 * @since 2021-02-02
 */
public interface GoodsSiteMapper extends BaseMapper<GoodsSite> {
    @Select("SELECT `goods_site`.id,`goods_site`.good_id,`goods_site`.`owner`,`goods`.title,`goods`.sub_img,`goods`.cover_img,`goods`.price,`goods`.store,`member`.user_name,`member`.avatar,`member`.grade,`store`.`name` FROM `goods_site`,`goods`,`member`,`store` WHERE `goods_site`.good_id=`goods`.id and `goods_site`.`owner`=`member`.id and `store`.id=`goods`.store and `goods_site`.`state`=1 and `goods_site`.type=3 order by RAND() limit 6")
    List<SiteListDto> vipList();

    @Select("SELECT `goods_site`.id,`goods_site`.good_id,`goods_site`.`owner`,`goods`.title,`goods`.sub_img,`goods`.cover_img,`goods`.price,`goods`.store,`member`.user_name,`member`.avatar,`member`.grade,`store`.`name` FROM `goods_site`,`goods`,`member`,`store` WHERE `goods_site`.good_id=`goods`.id and `goods_site`.`owner`=`member`.id and `store`.id=`goods`.store and `goods_site`.`state`=1 and `goods`.title like \"%${keyWord}%\" order by RAND() limit 6 ")
    List<SiteListDto> normalList(Page<SiteListDto> page, String keyWord);
}
